package cn.iocoder.yudao.module.xhyy.controller.app.knowledge;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;



import cn.iocoder.yudao.module.xhyy.controller.app.knowledge.vo.*;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.knowledge.KnowledgeDO;
import cn.iocoder.yudao.module.xhyy.service.knowledge.KnowledgeService;

@Tag(name = "用户 APP - 知识点")
@RestController
@RequestMapping("/xhyy/knowledge")
@Validated
public class AppKnowledgeController {

    @Resource
    private KnowledgeService knowledgeService;



    @GetMapping("/get")
    @Operation(summary = "获得知识点")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppKnowledgeRespVO> getKnowledge(@RequestParam("id") String id) {
        KnowledgeDO knowledge = knowledgeService.getKnowledge(id);
        return success(BeanUtils.toBean(knowledge, AppKnowledgeRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得知识点分页")
    public CommonResult<PageResult<AppKnowledgeRespVO>> getKnowledgePage(@Valid AppKnowledgePageReqVO pageReqVO) {
        PageResult<KnowledgeDO> pageResult = knowledgeService.getKnowledgePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppKnowledgeRespVO.class));
    }



}